import random
x = random.randint(0, 9)
flag = False
counte=0  # 初始 未猜中
while True:
    counte += 1
    try:
        y = int(input("输入猜测:"))
    except ValueError:
        print("is not number,请输入一个有效数据：")
        continue
    if y > 9:
        print("遗憾，太大了")
    elif y < 0:
        print("遗憾，太小了")
    else:
        print("预测{:.0f}次，您猜对了！".format(counte))
        break
        flag = True  # 设标志



